﻿Public Class CNodePacket
    Public Topic As String
    Public Body As String
    Public URL As String
End Class

Module modTree

    Public NodePacketCount As Integer = 0
    Public NodePacket() As CNodePacket

    Public Function AddNewNode(ByVal argParent As TreeView, ByVal argTopic As String, ByVal argTitle As String, ByVal argBody As String, ByVal argURL As String) As TreeNode

        NodePacketCount = NodePacketCount + 1
        ReDim Preserve NodePacket(NodePacketCount)
        Dim nx As Integer = NodePacketCount - 1
        NodePacket(nx) = New CNodePacket

        Dim node As TreeNode
        node = argParent.Nodes.Add(argTopic, argTitle)
        node.Tag = nx
        AddNewNode = node

        With NodePacket(nx)
            .Topic = argTopic
            .Body = argBody
            .URL = argURL
        End With

    End Function

    Public Function AddNewNode(ByVal argParent As TreeNode, ByVal argTopic As String, ByVal argTitle As String) As TreeNode
        AddNewNode = AddNewNode(argParent, argTopic, argTitle, "", "")
    End Function

    Public Function AddNewNode(ByVal argParent As TreeNode, ByVal argTopic As String, ByVal argTitle As String, ByVal argBody As String, ByVal argURL As String) As TreeNode
        NodePacketCount = NodePacketCount + 1
        ReDim Preserve NodePacket(NodePacketCount)
        Dim nx As Integer = NodePacketCount - 1
        NodePacket(nx) = New CNodePacket

        Dim node As TreeNode
        node = argParent.Nodes.Add(argTopic, argTitle)
        node.Tag = nx
        AddNewNode = node

        With NodePacket(nx)
            .Topic = argTopic
            .Body = argBody
            .URL = argURL
        End With
    End Function

End Module

